package com.kingland.zf.config;

import org.flywaydb.core.Flyway;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
@MapperScan("com.kingland.zf.mapper")
public class MybatisConfig {
    @Bean
    CommandLineRunner flyway(DataSource dataSource) {
        return new CommandLineRunner() {
            @Override
            public void run(String... args) throws Exception {
                Flyway flyway = Flyway.configure()
                        .schemas("user_access")
                        .dataSource(dataSource).load();
                flyway.migrate();
            }
        };
    }


}
